<template>
    <div class="mui-numbox" data-numbox-step='1' data-numbox-min='1' :data-numbox-max='max'>
        <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
        <input class="mui-numbox-input" type="number" @change="countChanged" value="1" ref="numbox"/>
        <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'
export default {
    mounted(){
        mui(".mui-numbox").numbox();
       // console.log(this.max,888);
        
    },
    methods:{
        countChanged(){
            console.log(this.$refs.numbox.value);
            this.$emit('getcount',parseInt(this.$refs.numbox.value))
        }
    },

    /* 接受父组件的属性 */
    props:["max"],
    watch:{
        max:function(newVal,oldVal){
            mui(".mui-numbox").numbox().setOption('max',newVal)
        }
    }
}
</script>
<style lang="less" scoped>

</style>
 